<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model="myinput">
        <ul>
            <li v-for="item in templist">{{item}}</li>
        </ul>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                myinput: "周",
                jinmajiang: {
                    list: ["周星驰", "周润发", "刘德华", "肖战"]
                },
                templist: []
            },
            watch: {
                myinput:{
                    handler(newValue) {
                        if(newValue === "") return this.templist = [];
                        this.templist = this.jinmajiang.list.filter((item)=> {
                            return item.indexOf(newValue) > -1
                        })
                    },
                    // 立即执行
                    immediate: true
                }
            }
        })
    </script>
</body>
</html>